/* possible error codes for pointer != NULL */
#define ER_ELEM -1          /* memory element is corrupted */
/* some constants */
#define SZBLN    8              /* block name length       */
#define LBLOCK 2048             /* block size in pool      */

#include <stdio.h>

struct a2elm                         /* element descriptor */
        {char dummy;                   /* safety signature */
         struct a2elm *next;           /*     next in list */
        };
typedef struct a2elm ELM;
struct a2bldsc                  /* descriptor of pool block*/
        {char name[SZBLN];      /* block name              */
         struct a2bldsc *next;  /* next in list            */
         double elm;        /* elements beginning in block */
        };
typedef struct a2bldsc BLDSC;
typedef struct                /* memory pool descriptor    */
        {BLDSC *block;        /* 1-st block in list        */
         ELM *frelm;          /* 1-st free element         */
         unsigned size;       /* size of element           */
         char *name;          /* pool name                 */
         long nblk;           /* number of blocks in pool  */
         long nelm;           /* number of active elements */
        } PDSC;

/*----------- programm entrys definition ------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/*---- a2mamers - control by error message output ---------*/
#define A2MA_CONFM  1 /* verification while message output */
#define A2MA_MSGON  2             /* put on message output */
#define A2MA_NOMSG  0           /* suppress message output */
int a2mamers(int s);
/*---------- a2macmp - comparing by 1-st name -------------*/
int a2macmp(char *f,char *s);
/*------- a2magb - allocation of memory block (through DOS)*/
void *a2magb(size_t size,char *name,char *prog);
/*----- a2mafb - releasing of memory block (through DOS) --*/
void *a2mafb(void *area,char *name,char *prog);

/*------ a2matr - setting trace regimes -------------------*/
#define A2MA_TRBLK  1             /* blocks tracing        */
#define A2MA_TRELM  2             /* elements tracing      */
#define A2MA_TROFF  0             /* no tracing            */
int a2matr(int tr,char *tp,char *tn);
/*---------- a2mage - memory element allocation -----------*/
void *a2mage(PDSC *p,char *prog);
/*------- a2mafe - memory element releasing ---------------*/
a2mafe(PDSC *p,void *elm,char *prog);
/*-------- a2mafp - releasing of whole memory pool --------*/
void a2mafp(PDSC *p,char *prog);
/*---------- a2mast - pull statistics output --------------*/
void a2mast(PDSC *p);
/*-- a2mace - checking of free memory elements list -------*/
a2mace(PDSC *p);
/*- a2macf - checking of free elements of system pools ----*/
/* returns 0 if O'K */
a2macf(void);
/* a2maFreeEmptyBlocksPool - frees all empty blocks of pool*/
/* returns number of freed blocks -------------------------*/
a2maFreeEmptyBlocksPool(PDSC *p);
/*- a2maFreeEmptyBlocks
		 - frees all empty blocks of system pools -*/
/* returns number of freed blocks -------------------------*/
a2maFreeEmptyBlocks(void);
#ifdef __cplusplus
}
#endif
/*---------------------------------------------------------*/

